clear
clear matrix
clear mata
set more off, perm
set matsize 11000
set maxvar 30000
cd /Users/zachbrown/Projects/PriceTransparency/Data/
global output /Users/zachbrown/Projects/PriceTransparency/Output

// Open visit dataset
use clean/radiology_visit_3.dta, clear

keep proc_class proc_id_radio_max visit_on_web
duplicates drop


gen proc_id_rad_web = proc_id_radio_max if visit_on_web==1
gen proc_id_rad_noweb = proc_id_radio_max if visit_on_web==0

collapse (count) proc_id_rad_web proc_id_rad_noweb, by(proc_class)

label list procclass
xpose, clear 

label var v1 "Computed Tomography (CT)"
label var v2 "Magnetic Resonance Imaging (MRI)"
label var v3 "X-Ray" 

egen total = rowtotal(v*)
label var total "Total"


estpost summarize v* if _n==2 // On web
eststo summA
estpost summarize v* if _n==3 // Not on web
eststo summB

esttab summA summB using $output/website_proc_availability_a1.tex, frag ///
	cells("mean(fmt(%6.0fc) label( ) )" ) ///
	substitute(_ \_  $  \$  %  \% ) ///
	collabels(none) booktabs gaps ///
	noobs nonumber label  nonote replace nomtitles nodepvars noisily

estpost summarize total if _n==2 // On web
eststo totA
estpost summarize  total if _n==3 // Not on web
eststo totB

esttab totA totB using $output/website_proc_availability_a2.tex, frag ///
	cells("mean(fmt(%6.0fc) label( ) )" ) ///
	substitute(_ \_  $  \$  %  \% ) ///
	collabels(none) booktabs gaps ///
	noobs nonumber label  nonote replace nomtitles nodepvars noisily
